package org.shijiagen.manager.service.impl;

import lombok.RequiredArgsConstructor;
import org.shijiagen.clients.UserClient;
import org.shijiagen.manager.service.UserService;
import org.shijiagen.param.CartListParam;
import org.shijiagen.param.PageParam;
import org.shijiagen.pojo.User;
import org.shijiagen.utils.R;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {

    private final UserClient userClient;

    @Override
    @Cacheable(key = "#param.currentPage+'-'+#param.pageSize",value = "list.user")
    public R userList(PageParam param) {
        return userClient.adminListPage(param);
    }

    @Override
    @CacheEvict(value = "list.user",allEntries = true)
    public R userRemove(CartListParam param) {
        return userClient.remove(param);
    }

    @Override
    @CacheEvict(value = "list.user",allEntries = true)
    public R userUpdate(User user) {
        return userClient.update(user);
    }

    @Override
    public R save(User user) {
        return userClient.save(user);
    }
}
